// TODO: comment

var Bounds = SMap.Class({
	init: function(left, bottom, right, top) {
		this.top = (top == null) ? 0 : parseFloat(top);
		this.bottom = (bottom == null) ? 0 : parseFloat(bottom);
		this.left = (left == null) ? 0 : parseFloat(left);
		this.right = (right == null) ? 0 : parseFloat(right);
    },
	getWidth: function() {
		return Math.abs(this.right - this.left);
	},
	getHeight: function() {
		return Math.abs(this.top - this.bottom);
	},
	getCenterXY: function() {
		return new XY((this.left + this.right) / 2, (this.top + this.bottom) / 2);
	},
	getCenterLonLat: function() {
		return new LonLat((this.left + this.right) / 2, (this.top + this.bottom) / 2);
	},
	contains: function(x, y) {
		contains = ((x >= Math.min(this.left, this.right)) && (x <= Math.max(this.left, this.right)) && 
			(y >= Math.min(this.bottom, this.top)) && (y <= Math.max(this.bottom, this.top)));
		return contains;
	},
	containsLonLat: function(ll) {
		return this.contains(ll.lon, ll.lat);
	},
	containsXY: function(xy) {
		return this.contains(xy.x, xy.y);
	},
	toArray: function() {
		return [this.left, this.bottom, this.right, this.top];
	},
	toString: function() {
		return format("{bounds: {left}, {bottom}, {right}, {top}}", this);
	},
	clone: function() {
		return new Bounds(this.left, this.bottom, this.right, this.top);
	}
});